package com.zyh.thread;

/**
 * @Author zyh
 * @Date 2024/8/7 11:49
 * @Description 使用匿名内部类
 */

public class ThreadDemo3 {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println(Thread.currentThread().getName()+"线程正在打印"+i);
                }
            }
        });
        t1.start();

        Thread t2 = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName()+"线程正在打印"+i);
            }
        },"线程B");
        t2.start();
    }
}
